package umlTool;

import org.w3c.dom.*;

/**
 * represents a field in a class
 * 
 * @author Mimo
 * 
 */
public class ClassField extends ClassMember {
	String initValue;

	public ClassField() {
		super();
	}

	public ClassField(Element elem) {
		super(elem);
		initValue = elem.getTextContent();
	}

	public Element saveToXml(Document doc) {
		Element elem = super.saveToXml(doc);
		elem.setTextContent(initValue);
		return elem;
	}

	public String classType() {
		return "classField";
	}

	@Override
	public void setComment(String comment) {
		this.comment = comment;
	}

	@Override
	public String getComment() {
		return comment;
	}

	public String toString() {
		StringBuilder s = new StringBuilder();
		s.append(access.toString() + " ");
		s.append(type + " ");
		s.append(name + " ");
		if (!initValue.isEmpty())
			s.append(" = " + initValue);
		s.append(";\n");
		return s.toString();
	}
}
